home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / programming / other / tandem / teaching / 60.asm < prev    next >
Assembly Source File  |  1999-09-06  |  10KB  |  382 lines

  1. * 60.asm     Demonstrate TLreqedit   version 0.01    8.6.99
  2.  
  3.  
  4.  include 'Front.i'
  5.  
  6.  
  7. ; TLreqedit is a comlex and powerful routine. It allows you to format
  8. ; individual characters & whole lines in many different ways. Although
  9. ; this program is long, that is because of programming the various buttons
  10. ; in the demo. TLreqedit is itself easy to use.
  11.  
  12.  
  13. ;text & styl data
  14. text: ds.b 100             ;text
  15. styl: ds.b 100             ;styl
  16.  
  17. jam1: ds.l 1               ;-1 if jam1
  18. case: ds.l 1               ;<> if case
  19. styb: ds.l 1               ;<> if styb
  20. fixt: ds.l 1               ;<> if fixt
  21. cspc: ds.l 1               ;cspc
  22. maxj: ds.l 1               ;maxj
  23. wdth: ds.l 1               ;text wdth (600, or 500 if shrt)
  24. ltyp: ds.l 1               ;justification
  25. revs: ds.l 1               ;<> if reversed
  26. crsr: ds.l 1               ;cursor
  27.  
  28. ;strings
  29. strings: dc.b 0
  30.  dc.b 'Demonstrate TLreqedit',0 ;1
  31.  dc.b 'Font Jam1 Case Styb Fixt Cspc Maxj Shrt Revs',0 ;2
  32.  dc.b 'Line formatting, editing',0 ;3
  33.  dc.b 'Font Style',0 ;4
  34.  dc.b 'Bold   Ctrl/B',0 ;5
  35.  dc.b 'Italic Ctrl/I',0 ;6
  36.  dc.b 'Wide   Ctrl/W',0 ;7
  37.  dc.b 'Shadow Ctrl/S',0 ;8
  38.  dc.b 'Superscript  Ctrl/Up arrow',0 ;9
  39.  dc.b 'Subscript    Ctrl/Dn arrow',0 ;10
  40.  dc.b 'Under/Overlining',0 ;11
  41.  dc.b 'Single Under Ctrl/U',0 ;12
  42.  dc.b 'Over         Ctrl/E',0 ;13
  43.  dc.b 'Under+Over   Ctrl/F',0 ;14
  44.  dc.b 'Double Under Ctrl/G',0 ;15
  45.  dc.b 'Dbl Under+Over  Ctrl/H',0 ;16
  46.  dc.b 'Dotted Under Ctrl/O',0 ;17
  47.  dc.b 'Strike Through  Ctrl/V',0 ;18
  48.  dc.b 'Justification',0 ;19
  49.  dc.b 'Right Justify  Ctrl/R',0 ;20
  50.  dc.b 'Full Justify   Ctrl/J',0 ;21
  51.  dc.b 'Center         Ctrl/C',0 ;22
  52.  dc.b 'Left Justify   Ctrl/L',0 ;23
  53.  dc.b 'Complement  Shift/Ctrl/C',0 ;24
  54.  dc.b 'Erase (x-out)  Ctrl/X',0 ;25
  55.  dc.b 'Undo        Shift/Ctrl/U',0 ;26
  56.  dc.b 'Restore     Shift/Ctrl/R',0 ;27
  57.  dc.b 'Space fill  Shift/Ctrl/S',0 ;28
  58.  dc.b 'Force Fixed    Ctrl/P',0 ;29
  59.  dc.b 'Specify inter-chr spaces (0-31, normally 0)',0 ;30
  60.  dc.b 'Draw Mode (Jam1 is demo only - not usually used if text editable)',0
  61.  dc.b 'Jam1  (normally for text display only)',0 ;32
  62.  dc.b 'Jam2  (for text display &/or text editing)',0 ;33
  63.  dc.b 'Fixed/Proportional',0 ;34
  64.  dc.b 'Force a proportional font to be shown fixed',0 ;35
  65.  dc.b 'Show font proportional/fixed as it normally is',0 ;36
  66.  dc.b 'Max full justify cspace (0-15 normally 5)(0 to force)',0 ;37
  67.  dc.b 'Show initial "AaBb" in chr style...',0 ;38
  68.  dc.b 'Unchanged - i.e. as "AaBb"',0 ;39
  69.  dc.b 'All upper case',0 ;40
  70.  dc.b 'All lower case',0 ;41
  71.  dc.b 'Small caps (works best for largish fonts)',0 ;42
  72.  dc.b 'Press <Help> for assistance!!!',0 ;43
  73.  dc.b 'Notes concerning this demo...',0 ;44
  74.  dc.b 0 ;45
  75.  dc.b '1. Click "Shrt" to make the demo make a short line, without',0
  76.  dc.b '   sideways scrolling, so you see better the effect of line',0 ;47
  77.  dc.b '   justification. Click it again so you can go back to',0
  78.  dc.b '   sideways scrolling.',0 ;49
  79.  dc.b 0 ;50
  80.  dc.b '2. If you choose "Jam1" the view mucks up when you type - this is',0
  81.  dc.b '   not a bug - jam1 is suitable for display only, but not typing.',0
  82.  dc.b '   The same applies also with case, which mucks up as soon as you',0
  83.  dc.b '   type. Have something showing before you choose either.',0 ;54
  84.  dc.b 0 ;55
  85.  dc.b '3. "Revs" (reverse) allows right-to-left typing. Presumably,',0 ;56
  86.  dc.b '   you''d also press Ctlr/r for right justify. n.b. reverse',0 ;57
  87.  dc.b '   does not allow horizontal scrolling. It is not guaranteed',0 ;58
  88.  dc.b '   to be compatible with all possible combinations of tags.',0 ;59
  89.  dc.b 'Style byte for text (e.g. 01=bold 02=italic)(0=none) 00-FF',0 ;60
  90.  
  91.  ds.w 0
  92.  
  93.  
  94. ment:
  95.  TLnm 1,3      ;Line formatting, editing
  96.  TLnm 2,4    ;  Font Style
  97.  TLnm 3,5    ;    Bold        Ctrl/b
  98.  TLnm 3,6    ;    Italic      Ctrl/i
  99.  TLnm 3,7    ;    Wide        Ctrl/w
  100.  TLnm 3,8    ;    Shadow      Ctrl/s
  101.  TLnm 3,9    ;    Superscript Ctrl/up
  102.  TLnm 3,10    ;    Subscript   Ctrl/down
  103.  TLnm 2,11    ;  Under/Overlining
  104.  TLnm 3,12    ;    Single Under   Ctrl/u
  105.  TLnm 3,13    ;    Over           Ctrl/e
  106.  TLnm 3,14    ;    Under+Over     Ctrl/f
  107.  TLnm 3,15    ;    Double Under   Ctrl/g
  108.  TLnm 3,16    ;    Dbl Under+Over Ctrl/h
  109.  TLnm 3,17    ;    Dotted Under   Ctrl/o
  110.  TLnm 3,18    ;    Strike Through
  111.  TLnm 2,19    ;  Justification
  112.  TLnm 3,20    ;    Right Justify Ctrl/r
  113.  TLnm 3,21    ;    Full Justify  Ctrl/j
  114.  TLnm 3,22    ;    Center        Ctrl/c
  115.  TLnm 3,23    ;    Left Justify  Ctrl/l
  116.  TLnm 3,29    ;    Force Fixed   Ctrl/p
  117.  TLnm 2,24    ;  Complement
  118.  TLnm 2,25    ;  Erase (x-out)  Ctrl/x
  119.  TLnm 2,26    ;  Undo           Shift/Ctrl/u
  120.  TLnm 2,27    ;  Restore        Shift/Ctrl/r
  121.  TLnm 2,28    ;  Space fill     Shift/Ctrl/s
  122.  TLnm 4,0      ;(End)
  123.  
  124.  
  125. ;demonstrate TLReqedit
  126. Program:
  127.  TLwindow #-1
  128.  TLwindow #0,#0,#0,#640,xxp_Height(a4),#640,xxp_Height(a4),#0,#strings+1
  129.  beq Pr_bad
  130.  TLreqinfo #44,#16         ;preliminary info
  131.  
  132.  TLreqmenu #ment           ;init menu
  133.  beq Pr_bad
  134.  TLreqmuset
  135.  
  136.  clr.l jam1                ;init line format data
  137.  clr.l case
  138.  clr.l styb
  139.  clr.l fixt
  140.  clr.l cspc
  141.  clr.l ltyp
  142.  move.l #5,maxj
  143.  move.l #600,wdth
  144.  clr.l revs
  145.  clr.l crsr
  146.  
  147.  lea text,a0               ;init text
  148.  clr.b (a0)
  149.  
  150.  tst.l case
  151.  bne.s Pr_some
  152.  tst.l jam1
  153.  beq.s Pr_none
  154. Pr_some:
  155.  move.l #'AaBb',(a0)       ;some init if case or jam1
  156.  clr.b 4(a0)
  157. Pr_none:
  158.  
  159.  clr.l styl
  160.  clr.b styl+4
  161.  
  162. Pr_font:                   ;choose a font
  163.  TLaslfont #1
  164.  beq Pr_bad
  165.  
  166. Pr_edit:                   ;(re-)edit the text
  167.  TLreqcls
  168.  TLnewfont #0,#0,#0
  169.  TLstring #2,#10,#5
  170.  moveq #6,d0
  171.  moveq #8,d1
  172. Pr_boxes:
  173.  TLreqbev d0,#4,#40,#10
  174.  add.w #40,d0
  175.  dbra d1,Pr_boxes
  176.  
  177.  move.l xxp_AcWind(a4),a5  ;advise to ask for help
  178.  move.w #$0200,xxp_FrontPen(a5)
  179.  TLstring #43,#382,#5
  180.  subq.b #1,xxp_FrontPen(a5)
  181.  
  182.  TLnewfont #1,#0,#0
  183.  bne.s Pr_cont
  184.  
  185. Pr_badf:
  186.  move.l #10,xxp_errn(a4)
  187.  bra Pr_bad
  188.  
  189. Pr_cont:
  190.  move.l xxp_AcWind(a4),a5
  191.  move.w #$0100,xxp_FrontPen(a5)
  192.  
  193.  move.l xxp_FSuite(a4),a0  ;set d7 = font ysize
  194.  add.w #xxp_fsiz,a0
  195.  move.l xxp_plain(a0),a1
  196.  moveq #0,d7
  197.  move.w tf_YSize(a1),d7
  198.  
  199.  addq.w #2,d7              ;box around tablet
  200.  TLreqarea #6,#19,#504,d7,#2
  201.  TLreqbev #6,#19,#504,d7,box,,#3
  202.  
  203.  sub.w #140,a7             ;room for 17 tags
  204.  move.l a7,a0
  205.  move.l #xxp_xtext,(a0)+   ;tag 1:  text address
  206.  move.l #text,(a0)+
  207.  tst.l styb                ;(no styl address if styb)
  208.  bne.s Pr_tag3
  209.  move.l #xxp_xstyl,(a0)+   ;tag 2:  styl address
  210.  move.l #styl,(a0)+
  211. Pr_tag3:
  212.  move.l #xxp_xmaxt,(a0)+   ;tag 3:  tablet width
  213.  move.l #500,(a0)+
  214.  move.l #xxp_xmaxw,(a0)+   ;tag 4:  max line width
  215.  move.l wdth,(a0)+
  216.  move.l #xxp_xmaxc,(a0)+   ;tag 5:  max chrs
  217.  move.l #80,(a0)+
  218.  move.l #xxp_xcrsr,(a0)+   ;tag 6:  crsr
  219.  move.l crsr,(a0)+
  220.  move.l #xxp_xmenu,(a0)+   ;tag 7:  use menu 0
  221.  move.l #0,(a0)+
  222.  move.l #xxp_xforb,(a0)+   ;tag 8:  forbids - none
  223.  clr.l (a0)+
  224.  move.l #xxp_xjam1,(a0)+   ;tag 9:  jam1
  225.  move.l jam1,(a0)+
  226.  move.l #xxp_xcase,(a0)+   ;tag 10: case
  227.  move.l case,(a0)+
  228.  move.l #xxp_xstyb,(a0)+   ;tag 11: styb
  229.  move.l styb,(a0)+
  230.  move.l #xxp_xffix,(a0)+   ;tag 12: fixt
  231.  move.l fixt,(a0)+
  232.  move.l #xxp_xcspc,(a0)+   ;tag 13: cspc
  233.  move.l cspc,(a0)+
  234.  move.l #xxp_xmaxj,(a0)+   ;tag 14: maxj
  235.  move.l maxj,(a0)+
  236.  move.l #xxp_xfgbg,(a0)+   ;tag 15: pens
  237.  move.l #$00000100,(a0)+
  238.  move.l #xxp_xltyp,(a0)+   ;tag 16: ltyp
  239.  move.l ltyp,(a0)+
  240.  move.l #xxp_xrevs,(a0)+   ;tag 17: revs
  241.  move.w revs,d0
  242.  ext.l d0
  243.  move.l d0,(a0)+
  244.  clr.l (a0)                ;delimit tags
  245.  move.l a7,a0
  246.  TLreqedit #8,#20,a0       ;do the edit
  247.  add.w #140,a7
  248.  
  249.  move.l xxp_FWork(a4),a0   ;save the results
  250.  move.l a0,a1
  251.  add.w #256,a1
  252.  lea text,a2
  253.  clr.b 99(a0)              ;(max 99 chrs to be safe - can't be >80?)
  254.  lea styl,a3
  255. Save:
  256.  move.b (a1)+,(a3)+
  257.  move.b (a0)+,(a2)+
  258.  bne Save
  259.  
  260.  move.b xxp_chnd+2(a4),d4  ;get final ltyp
  261.  and.b #3,d4
  262.  move.b d4,ltyp+3
  263.  move.l xxp_crsr(a4),crsr  ;get final crsr
  264.  
  265.  cmp.w #5,d0               ;go if click off tablet
  266.  beq.s Pr_clik
  267.  cmp.w #1,d0               ;quit if Esc
  268.  beq Pr_quit
  269.  cmp.w #13,d0              ;quit if close window
  270.  beq Pr_quit
  271.  cmp.w #8,d0               ;recycle if 0-7
  272.  bcs Pr_edit
  273.  cmp.w #12,d0              ;recycle if 12+
  274.  bcc Pr_edit
  275.  bra Pr_badf               ;else, bad (only can't attach font possible)
  276.  
  277. Pr_clik:
  278.  move.l xxp_AcWind(a4),a5
  279.  move.l xxp_kybd+4(a4),d0
  280.  sub.w xxp_LeftEdge(a5),d0
  281.  bcs Pr_edit
  282.  move.l xxp_kybd+8(a4),d1
  283.  sub.w xxp_TopEdge(a5),d1
  284.  bcs Pr_edit
  285.  sub.w #6,d0
  286.  bcs Pr_edit
  287.  divu #40,d0               ;d0 = 0-8 if box clicked
  288.  cmp.w #9,d0
  289.  bcc Pr_edit
  290.  cmp.w #4,d1
  291.  bcs Pr_edit
  292.  cmp.w #15,d1
  293.  bcc Pr_edit
  294.  cmp.w #1,d0
  295.  bcs Pr_font               ;go to whichever box clicked
  296.  beq Pr_jam1
  297.  cmp.w #3,d0
  298.  bcs Pr_case
  299.  beq Pr_styb
  300.  cmp.w #5,d0
  301.  bcs Pr_fixt
  302.  beq Pr_cspc
  303.  cmp.w #7,d0
  304.  bcs Pr_maxj
  305.  beq Pr_shrt
  306.  cmp.w #9,d0
  307.  bcs Pr_revs
  308.  bra Pr_edit
  309.  
  310. Pr_jam1:                   ;get jam1 (0/-1)
  311.  clr.l jam1
  312.  TLreqchoose #31,#2
  313.  cmp.w #1,d0
  314.  bne Pr_edit
  315.  subq.l #1,jam1
  316.  bra Pr_edit
  317.  
  318. Pr_case:                   ;get case (0-3)
  319.  TLreqchoose #38,#4
  320.  subq.l #1,d0
  321.  bcs Pr_edit
  322.  move.l d0,case
  323.  bra Pr_edit
  324.  
  325. Pr_styb:                   ;get styb (0,1-255)
  326.  clr.b (a4)
  327.  TLreqinput #60,hex,#2
  328.  beq Pr_edit
  329.  move.b d0,styb+3
  330.  bra Pr_edit
  331.  
  332. Pr_fixt:                   ;get fixt (0/-1)
  333.  clr.l fixt
  334.  TLreqchoose #34,#2
  335.  cmp.w #1,d0
  336.  bne Pr_edit
  337.  subq.l #1,fixt
  338.  bra Pr_edit
  339.  
  340. Pr_cspc:                   ;get cspc (0-31)
  341.  clr.b (a4)
  342.  TLreqinput #30,num,#2
  343.  beq Pr_edit
  344.  cmp.w #32,d0
  345.  bcc Pr_cspc
  346.  move.l d0,cspc
  347.  bra Pr_edit
  348.  
  349. Pr_maxj:                   ;get maxj (0-15)
  350.  clr.b (a4)
  351.  TLreqinput #37,num,#2
  352.  beq Pr_edit
  353.  cmp.w #16,d0
  354.  bcc Pr_maxj
  355.  move.l d0,maxj
  356.  bra Pr_edit
  357.  
  358. Pr_shrt:
  359.  tst.l revs               ;(forbid choosing long if revs)
  360.  bmi Pr_edit
  361.  move.l wdth,d0
  362.  move.l #500,wdth
  363.  cmp.l #600,d0
  364.  beq Pr_edit
  365.  move.l #600,wdth
  366.  bra Pr_edit
  367.  
  368. Pr_revs:
  369.  move.l revs,d0
  370.  eori.l #-1,d0
  371.  move.l d0,revs
  372.  bpl Pr_edit
  373.  move.l #500,wdth          ;(forbid horz scrolling if revs)
  374.  bra Pr_edit
  375.  
  376. Pr_bad:                    ;here to report error
  377.  TLerror
  378.  TLreqchoose
  379.  
  380. Pr_quit:
  381.  rts
  382.